package com.dean.service.impl;

import com.dean.exception.DeanRuntimeException;
import com.dean.service.DeanExcelExportService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.OutputStream;
import java.util.Map;

public class DeanExcelExportServiceImpl implements DeanExcelExportService {
    private static final Logger logger = LoggerFactory.getLogger(DeanExcelExportServiceImpl.class);
    private static final String XLSX = ".xlsx";
    private static final String XLS = ".xls";
    @Override
    public void exportExcel(String tempName, OutputStream outputStream, Map<String, Object> context) {
        DeanExcelExportService exportService = null;
        if(tempName.endsWith(XLS)){
            exportService = new DeanXlsExportServiceImpl();
        }else if(tempName.endsWith(XLSX)){
            exportService = new DeanXlsxExportServiceImpl();
        }else{
            DeanRuntimeException.throwException(996,"不支持的文件格式");
        }
        exportService.exportExcel(tempName,outputStream,context);
    }
}
